$(function () {
    $("#table").bootstrapTable({
        method: "post",
        contentType: "application/json",
        url: "/find",
        striped: true,
        pageNumber: 1,
        pagination: true,
        sidePagination: 'server',
        pageSize: 2,
        pageList: [2, 3, 4, 5],
        queryParams: function (param) {
            return {
                // 计算页号(当前页)
                page: (param.offset / param.limit) + 1,
                // 计算页大小
                pageNum: param.limit,

                sname:$("#sname").val(),

                tid:$("#tid").val(),
            }
        },
        columns: [
            {title: "编号", field: "sid", align: "center"},
            {title: "种类", field: "tid", align: "center"},
            {title: "名称", field: "sname", align: "center"},
            {title: "颜色", field: "color", align: "center"},
            {title: "产地", field: "adress", align: "center"},
            {title: "价格", field: "price", align: "center"},
            {title: "库存", field: "num", align: "center"},
            {title: "生产日期", field: "date", align: "center"},
            {title: "操作", field: "sid", align: "center",
                formatter: function (value, row, index) {
                    let btn1 = "<button class=\"btn btn-primary\" data-toggle=\"modal\" data-target=\"#myModal\" onclick=\"xg()\">修改</button>"
                    let btn2 = "<button class='btn btn-warning btn-sm' onclick='sc("+value+")'>删除</button>"
                    return btn1 + "&nbsp;" + btn2;
                }
            },
        ]
    })

    //查询方法
    $("#cx").click(function () {
        $("#table").bootstrapTable("refresh");
    })

})